home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / c_course.zip / PRINTDAT.C < prev    next >
Text File  |  1989-12-30  |  837b  |  27 lines

  1. /*     PRINTDAT.C   printer as a pointer to a file   */
  2.  
  3. /* In this example a single character is read from the file and printed.
  4. This is in a one-at-a-time loop until it sees and EOF.    */
  5.  
  6. #include "stdio.h"
  7.  
  8. main()
  9. {
  10. FILE *funny,*printer;
  11. int c;
  12.  
  13.    funny = fopen("TENLINES.TXT","r"); /* open input file     */
  14.    printer = fopen("PRN","w");        /* open printer file   */
  15.  
  16.    do {
  17.       c = getc(funny);    /* got one character from the file */
  18.       if (c != EOF) {
  19.          putchar(c);      /* display it on the monitor       */
  20.          putc(c,printer); /* print the character             */  
  21.       }
  22.    } while (c != EOF);    /* repeat until EOF (end of file)  */
  23.  
  24.    fclose(funny);
  25.    fclose(printer);
  26. }
  27.